<template>
  <div class="robot-clue-container">
    <div class="tabs-wrapper">
      <el-tabs v-model="activeName" class="enhanced-tabs" @tab-click="handleClick">
        <el-tab-pane name="1" class="tab-pane">
          <template #label>
            <div class="tab-label">
              <Icon icon="ep:robot" class="tab-icon" />
              <span class="tab-text">客户回收规则</span>
            </div>
          </template>
        </el-tab-pane>
        <el-tab-pane name="2" class="tab-pane">
          <template #label>
            <div class="tab-label">
              <Icon icon="ep:setting" class="tab-icon" />
              <span class="tab-text">线索回收规则</span>
            </div>
          </template>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="content-wrapper">
      <div class="content-container">
        <CustomerPoolConfig v-if="activeName == '1'" :moduleId="props.moduleId" />
        <CluePoolConfig v-if="activeName == '2'" :moduleId="props.moduleId" />
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import CustomerPoolConfig from './CustomerPoolConfig.vue'
import CluePoolConfig from './CluePoolConfig.vue'

const activeName = ref('1') // 右侧tab当前选项

const props = defineProps({
  moduleId: {
    type: Number
  }
})

// 初始化
onMounted(() => {})
</script>
<style scoped lang="scss">
// 主题色变量
$primary-color: #0052cc;
$primary-light: rgba(0, 82, 204, 0.1);
$primary-border: rgba(0, 82, 204, 0.3);
$success-color: #67c23a;
$warning-color: #e6a23c;
$danger-color: #f56c6c;
$info-color: #909399;
$text-primary: #303133;
$text-regular: #606266;
$text-secondary: #909399;
$text-placeholder: #c0c4cc;
$border-color: #dcdfe6;
$border-light: #e4e7ed;
$bg-color: #f5f7fa;
$shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
$shadow-base:
  0 2px 4px rgba(0, 0, 0, 0.12),
  0 0 6px rgba(0, 0, 0, 0.04);
$border-radius: 12px;
$border-radius-small: 8px;

.robot-clue-container {
  padding: 0;
  background: $bg-color;

  @media (max-width: 768px) {
    padding: 0;
  }
}

/* 标签页头部 */
.tab-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, $warning-color 0%, #faad14 100%);
  color: white;
  margin-bottom: 16px;

  @media (max-width: 768px) {
    padding: 16px 20px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
    margin-bottom: 12px;
  }

  .header-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: $border-radius-small;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;

    @media (max-width: 768px) {
      width: 36px;
      height: 36px;
      font-size: 16px;
    }
  }

  .header-content {
    flex: 1;
    margin-left: 12px;

    @media (max-width: 768px) {
      margin-left: 0;
    }
  }

  .header-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;

    @media (max-width: 768px) {
      font-size: 16px;
    }
  }

  .header-subtitle {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;

    @media (max-width: 768px) {
      font-size: 12px;
    }
  }
}

/* 标签页导航 */
.tabs-wrapper {
  background: white;
  border-radius: $border-radius $border-radius 0 0;
  box-shadow: $shadow-light;
  border: 1px solid $border-light;
  border-bottom: none;
  overflow: hidden;
}

.enhanced-tabs {
  :deep(.el-tabs__header) {
    margin: 0;
    background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%);
    border-bottom: 2px solid $primary-light;
  }

  :deep(.el-tabs__nav-wrap) {
    padding: 0 24px;

    @media (max-width: 768px) {
      padding: 0 16px;
    }
  }

  :deep(.el-tabs__nav) {
    border: none;
    display: flex;
    width: 100%;

    @media (max-width: 768px) {
      flex-direction: column;
      width: 100%;
    }
  }

  :deep(.el-tabs__item) {
    flex: 1;
    padding: 16px 20px;
    border: none;
    color: $text-regular;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    text-align: center;

    &:hover {
      color: $primary-color;
      background: $primary-light;
    }

    &.is-active {
      color: $primary-color;
      background: white;
      font-weight: 600;

      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 60%;
        height: 3px;
        background: linear-gradient(90deg, $primary-color 0%, #1d4ed8 100%);
        border-radius: 2px;
      }
    }

    @media (max-width: 768px) {
      padding: 14px 16px;
      font-size: 14px;

      &.is-active::after {
        width: 80%;
      }
    }
  }

  :deep(.el-tabs__active-bar) {
    display: none;
  }

  :deep(.el-tabs__content) {
    padding: 0;
  }
}

.tab-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  @media (max-width: 768px) {
    gap: 6px;
  }

  .tab-icon {
    font-size: 16px;
    transition: all 0.3s ease;

    @media (max-width: 768px) {
      font-size: 14px;
    }
  }

  .tab-text {
    font-size: 14px;
    white-space: nowrap;

    @media (max-width: 768px) {
      font-size: 13px;
    }
  }
}

/* 内容区域 */
.content-wrapper {
  background: white;
  border-radius: 0 0 $border-radius $border-radius;
  box-shadow: $shadow-light;
  border: 1px solid $border-light;
  border-top: none;
  min-height: 400px;
  overflow: hidden;

  @media (max-width: 768px) {
    min-height: 300px;
  }
}

.content-container {
  padding: 24px;
  background: white;
  border-radius: $border-radius-small;
  min-height: 350px;

  @media (max-width: 768px) {
    padding: 16px;
    min-height: 250px;
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .robot-clue-container {
    background: #1f2937;
  }

  .tabs-wrapper,
  .content-wrapper {
    background: #374151;
    border-color: #4b5563;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .content-container {
    background: #374151;
  }

  .header-title {
    color: #f9fafb;
  }

  .header-subtitle {
    color: rgba(249, 250, 251, 0.9);
  }

  .enhanced-tabs {
    :deep(.el-tabs__header) {
      background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
      border-bottom-color: #6b7280;
    }

    :deep(.el-tabs__item) {
      color: #d1d5db;

      &:hover {
        color: #60a5fa;
        background: rgba(96, 165, 250, 0.1);
      }

      &.is-active {
        color: #60a5fa;
        background: #374151;

        &::after {
          background: linear-gradient(90deg, #60a5fa 0%, #93c5fd 100%);
        }
      }
    }
  }
}

/* 响应式优化 */
@media (max-width: 480px) {
  .tab-header {
    padding: 12px 16px;
  }

  .enhanced-tabs {
    :deep(.el-tabs__nav-wrap) {
      padding: 0 12px;
    }

    :deep(.el-tabs__item) {
      padding: 12px 14px;
      font-size: 13px;
    }
  }

  .tab-label {
    gap: 4px;

    .tab-icon {
      font-size: 13px;
    }

    .tab-text {
      font-size: 12px;
    }
  }

  .content-container {
    padding: 12px;
    min-height: 200px;
  }
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content-container {
  animation: fadeInUp 0.3s ease-out;
}

/* 滚动条美化 */
.content-container {
  &::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  &::-webkit-scrollbar-track {
    background: $bg-color;
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: $border-color;
    border-radius: 3px;
    transition: all 0.3s ease;

    &:hover {
      background: $primary-color;
    }
  }
}

/* 标签页切换动画 */
.enhanced-tabs {
  :deep(.el-tabs__item) {
    &::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: $primary-light;
      opacity: 0;
      transition: opacity 0.3s ease;
      z-index: -1;
    }

    &:hover::before {
      opacity: 1;
    }

    &.is-active::before {
      opacity: 0;
    }
  }
}
</style>
